package com.github.binarywang.demo.wx.mp.controller;

import com.github.binarywang.demo.wx.mp.config.RedisConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 *  redis
 */
@Slf4j
@RestController
@RequestMapping("/wx/redis")
public class RedisController {
    @Autowired
    private RedisConfig redis;

    @GetMapping("/test")
    public void test(){
        // redis服务初始化
        JedisPool jedisPool = new JedisPool(redis.getHost(),redis.getPort());
        Jedis jedis = jedisPool.getResource();
        jedis.set("test1","redis链接成功");
        String test = jedis.get("test1");
        log.info(test);
    }

}
